<script lang="ts" setup>
import { ref } from 'vue'
import { Menu as IconMenu, Message, Setting } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

const item = {
  date: '2024-11-05',
  name: '北京昌平校区黑马程序员',
  address: '北京市昌平区回龙观西三旗金燕龙',
}
const tableData = ref(Array.from({ length: 20 }).fill(item))


const handleCommand = (command: string) => {
  if (command === 'github') {
    ElMessage({
      message: '去github吧',
      type: 'success',
    })
  }
}
</script>

<template>
  <el-container class="layout-container-demo" style="height: 500px">
    <!-- 侧边 -->
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu :default-openeds="['2', '3']">
          <el-menu-item index="1">
            <el-icon>
              <message />
            </el-icon>工作台
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><icon-menu /></el-icon>园区管理
            </template>
            <el-menu-item index="2-1">楼宇管理</el-menu-item>
            <el-menu-item index="2-2">企业管理</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon>
                <setting />
              </el-icon>行车管理
            </template>
            <el-menu-item index="3-1">区域管理</el-menu-item>
            <el-menu-item index="3-2">月卡管理</el-menu-item>
            <el-menu-item index="3-3">停车缴费管理</el-menu-item>
            <el-menu-item index="3-4">计费规则管理</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <div class="toolbar">
          <el-dropdown @command="handleCommand">
            <el-icon style="margin-right: 8px; margin-top: 1px">
              <setting />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item command="github">仓库地址</el-dropdown-item>
                <el-dropdown-item command="userinfo">个人信息</el-dropdown-item>
                <el-dropdown-item command="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <span>张三丰</span>
        </div>
      </el-header>

      <el-main>
        <el-scrollbar>
          <el-table :data="tableData">
            <el-table-column prop="date" label="日期" width="200" />
            <el-table-column prop="name" label="品牌" width="450" />
            <el-table-column prop="address" label="详细地址" />
          </el-table>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>



<style scoped>
.layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}

.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}

.layout-container-demo .el-menu {
  border-right: none;
}

.layout-container-demo .el-main {
  padding: 0;
}

.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
